package chen.web.config.spring;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import chen.web.antispam.CaptchaStore;
import chen.web.antispam.JudgeStore;
import chen.web.event.EventSupport;
import chen.web.forum.AntiSpamTopicManager;
import chen.web.forum.CategoryManager;
import chen.web.forum.ForumAccountLoader;
import chen.web.forum.SecurityTopicManager;
import chen.web.forum.TopTopicCachedTopicManager;
import chen.web.forum.TopicManager;
import chen.web.forum.TopicManagerEventFirer;
import chen.web.forum.TopicManagerImpl;
import chen.web.widget.WidgetManagerFactory;
import chen.web.widget.vote.VoteManager;

@Configuration
public class TopicManagerConfig {

	//分类管理
	private @Autowired CategoryManager categoryManager = null;
	//投票管理
	private @Autowired VoteManager voteManager = null;
	
	private @Autowired EventSupport es;
	private @Autowired ForumAccountLoader forumAccountLoader;
	private @Autowired JudgeStore judgeStore;
	private @Autowired CaptchaStore captchaStore;
	
	//帖子管理
	public @Bean TopicManager topicManager(){
		WidgetManagerFactory widgetManagerFactory = new WidgetManagerFactory(voteManager);
		TopicManager tm = new TopicManagerImpl(forumAccountLoader, categoryManager, widgetManagerFactory);
		tm = new TopTopicCachedTopicManager(tm);
		tm = new TopicManagerEventFirer(tm, es);
		tm = new SecurityTopicManager(tm, categoryManager);
		tm = new AntiSpamTopicManager(tm, judgeStore, captchaStore);
		return tm;
	}
}
